import React, { useState } from 'react';
import { Layout, theme } from 'antd';
import { Outlet } from 'react-router-dom';
import Sidebar from './components/Sidebar';
import Header from './components/Header';
import TechEffects from '../components/TechEffects';

const { Content } = Layout;

const BasicLayout: React.FC = () => {
  const [collapsed, setCollapsed] = useState(false);
  const {
    token: { colorBgContainer, borderRadiusLG },
  } = theme.useToken();

  return (
    <Layout style={{ minHeight: '100vh' }}>
      <TechEffects />
      <Sidebar collapsed={collapsed} />
      <Layout style={{ marginLeft: collapsed ? 80 : 280, transition: 'margin-left 0.2s' }}>
        <Header
          collapsed={collapsed}
          onToggle={() => setCollapsed(!collapsed)}
          style={{
            background: colorBgContainer,
            position: 'fixed',
            top: 0,
            right: 0,
            left: collapsed ? 80 : 280,
            zIndex: 100,
            transition: 'left 0.2s',
          }}
        />
        <Content
          style={{
            margin: '80px 16px 16px 16px',
            padding: 24,
            minHeight: 'calc(100vh - 96px)',
            background: colorBgContainer,
            borderRadius: borderRadiusLG,
          }}
        >
          <Outlet />
        </Content>
      </Layout>
    </Layout>
  );
};

export default BasicLayout;
